Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enable paths with junction inside windows #5245

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

blaubaer
Copy link

This is a workaround for the behavior of filepath.EvalSymlinks which errors with syscall.ENOTDIR if the provided path does include a Junction on Windows. Junctions can happen if a volume is mounted inside another drive as a subdirectory, for example. This can be usually happen if used with the feature Dev Drives and this replaces existing directories.

See original issue golang/go#40180. This issue is currently unresolved, and the ticket is leaning towards leaving this to the interpretation of the evaluating code rather than handling it within filepath.EvalSymlinks itself.

As syscall.ENOTDIR is only returned when calling filepath.EvalSymlinks on Windows if a part of the presented path is a Junction and nothing before was a symlink, we simply treat this as NOT symlink, because a symlink above the Junction does not make sense at all.

Copy link

boring-cyborg bot commented Dec 23, 2024

Hey, thank you for opening your first Pull Request !

@CLAassistant
Copy link

CLAassistant commented Dec 23, 2024

CLA assistant check
All committers have signed the CLA.

@ldez ldez added the platform: windows Issue that is related to Windows label Dec 23, 2024
@blaubaer blaubaer marked this pull request as draft December 23, 2024 13:05
@ldez ldez self-requested a review December 23, 2024 13:17
@blaubaer blaubaer marked this pull request as ready for review December 23, 2024 13:23
@blaubaer
Copy link
Author

@ldez I really tried to add tests at first. Because of the required complexity of the system requirements, like having a junction that needs to be created by the test itself and so, I tried to make the impact as simple as possible instead and tested it on my own machine instead.

@ldez ldez added feedback required Requires additional feedback and removed feedback required Requires additional feedback labels Dec 23, 2024
@ldez
Copy link
Member

ldez commented Dec 24, 2024

Have to try if winsymlink=1 + go1.23 changes the behavior?

@ldez ldez added the feedback required Requires additional feedback label Dec 24, 2024
@blaubaer
Copy link
Author

blaubaer commented Dec 24, 2024

winsymlink=0 works on go1.23, because from go1.23 on this behavior defaults to winsymlink=1 and in previous versions versions to winsymlink=0. With winsymlink=1 the actual behavior started to get problematic (see official documentation).

Potentially it might be also possible to drop godebug winsymlink=0 into the go.mod, but to have a debug statement in a product for release feels not right. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback required Requires additional feedback platform: windows Issue that is related to Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants